import request from '@/utils/request';
import { IotDeviceQuery, IotDeviceForm, IotDeviceVO } from './types';
import { AxiosPromise } from 'axios';

// 查询设备列表
export function listDevice(query: IotDeviceQuery): AxiosPromise<IotDeviceVO[]> {
  return request({
    url: '/system/iot/device/list',
    method: 'get',
    params: query
  });
}

// 查询设备详细
export const getDevice = (deviceId: string | number): AxiosPromise<IotDeviceVO> => {
  return request({
    url: '/system/iot/device/' + deviceId,
    method: 'get'
  });
};

// 新增设备
export const addDevice = (data: IotDeviceForm) => {
  return request({
    url: '/system/iot/device',
    method: 'post',
    data: data
  });
};

// 修改设备
export const updateDevice = (data: IotDeviceForm) => {
  return request({
    url: '/system/iot/device',
    method: 'put',
    data: data
  });
};

// 删除设备
export const delDevice = (deviceId: string | number | Array<string | number>) => {
  return request({
    url: '/system/iot/device/' + deviceId,
    method: 'delete'
  });
};
